package com.lh.process.engine.instance;

import com.lh.process.engine.process.Processor;

/**
 * @author: linghao
 * @since: 2022/10/22
 */
public class DefaultProcessInstanceCreator implements ProcessorInstanceCreator{
    @Override
    public Processor newInstance(String className, String name) throws Exception {
        Class<?> aClass = Class.forName(className);
        Object o = aClass.newInstance();
        if(!(o instanceof Processor)){
            throw new IllegalArgumentException("类" + className + "不是Processor实例");
        }
        Processor processor = (Processor) o;
        processor.setName(name);
        return processor;
    }
}
